package com.twu.biblioteca;

public class CustomerDetails {

    String customerName;
    String customerId;
    String phoneNumber;
    String username;
    String customerPwd;
    String bookReserved;
    String movieReserved;
    int customerNumber;
    boolean loggedInFlag;

    CustomerDetails(String customerName,String customerId,String phoneNumber,String username,String customerPwd,int customerNumber,boolean loggedInFlag)
    {
        this.customerName=customerName;
        this.customerId=customerId;
        this.phoneNumber=phoneNumber;
        this.username=username;
        this.customerPwd=customerPwd;
        this.customerNumber=customerNumber;
        this.loggedInFlag=loggedInFlag;
        //this.bookReserved=bookReserved;
    }

    public void bookReserve(Book bookDetails)
    {
        int numberOfCopies = bookDetails.getNumberOfCopies();
        if (numberOfCopies > 0)
        {
            bookDetails.updateNumberOfCopies();
            bookReserved=bookDetails.getBookName();
            showBookDetails();
        }
        else
        {
            System.out.println("Sorry, we don't have the book yet!");
        }
    }

    public void showBookDetails()
    {
        System.out.println(customerName + "\t"
                           + customerId + "\t"
                           + phoneNumber + "\t"
                           + bookReserved +"\t" );
    }

    public int LogIn(String username,String customerPwd)
    {

        if (username.equals(this.username) && customerPwd.equals(this.customerPwd))
        {
            this.loggedInFlag=true;
            return this.customerNumber;
        }
        return 0;
    }

    public void movieReserve(Movie movieDetails)
    {
        int numberOfCopies = movieDetails.getNumberOfCopies();
        if (numberOfCopies > 0)
        {
            movieDetails.updateNumberOfCopies();
            movieReserved=movieDetails.getMovieName();
            showMovieDetails();
        }
        else
        {
            System.out.println("Sorry, we don't have the Movie yet!");
        }
    }

    public void showMovieDetails()
    {
        System.out.println(customerName + "\t"
                + customerId + "\t"
                + phoneNumber + "\t"
                + movieReserved +"\t" );
    }
}
